\section{Dynamics}
This section answers questions related to the dynamics of the robot.

\subsection{Question 1}
Since the link is static, the torque is only affected by potential energy. Therefore, torque $\tau$ can be calculated directly from $\phi$.

\begin{figure}[htpb]
  \vspace{6cm}
  \caption{motor driving a uniform bar}
\end{figure}

\begin{equation*}
  V = m g \frac{1}{2} l \cdot \sin(q)
\end{equation*}
\begin{equation}
  \begin{split}
  \tau &= \phi(q) = \frac{\partial V}{\partial q} \\
       &= \frac{1}{2} m g l \cdot \cos(q)
  \end{split}
\end{equation}

The maximum torque occurs at $q = 0^\circ$ or when the link is horizontal. 
\begin{equation*}
  \begin{split}
  \tau _{max} = \tau {\vert}_{q=0^\circ} &= \frac{1}{2}mgl \\
                                          &= \frac{1}{2} (1)(9.8)(1) \\
					  &= 4.9 \text{Nm}
  \end{split}
\end{equation*}
Assuming no gravity, the torque equation is reduced to (\ref{eq:torque_without_gravity}). 
\begin{equation}
  \tau = D(q) \ddot q
  \label{eq:torque_without_gravity}
\end{equation}
From the Dynamics handout from class, it is found that
\begin{equation}
  D(q) = \frac{1}{3}ml^2
\end{equation}

Also, to accelerate from rest to an angular velocity of 1 rad/s in 1 second, a constant acceleration of 1 rad/s$^2$ is required. Substitute those values into (\ref{eq:torque_without_gravity}):
\begin{equation*}
  \begin{split}
  \tau &= \frac{1}{3}ml^2 \cdot \ddot q \\
       &= \frac{1}{3} (1)(1)^2 \cdot (1) \\
       &= 0.33 \text{Nm}
  \end{split}
\end{equation*}

A direct drive robot would require large motors to produce this torque because they do not have gearing to multiply the motor torque.

\subsection{Question 2}
Given:
\begin{gather}
  m_3 l_{c3} l_2 = m_4 l_{c4} l_1 \label{eq:cond6} \\
  m_2 l_{c2} + m_3 l_2 = m_4 l_{c4} \label{eq:cond7}
\end{gather}
Isolate for $m_4 l_{c4}$ in both equations, and then equate:
\begin{equation*}
  m_2 l_{c2} + m_3 l_2 = m_3 l_{c3} l_2
\end{equation*}
Rearrange to:
\begin{equation}
  m_2 l_{c2} = (l_{c3} - l_1)m_3 l_2 / l_1
\end{equation}
The equation shows that $l_{c3}$ must be greater than $l_1$ in order for all the mass and length values to be positive and valid. This can be accomplished by extending link 3 beyond the pivot with link 4 and add counterbalance weight so that $l_{c3}$ is greater than $l_3$. Since $l_3 = l_1$, this will also ensure that $l_{c3}$ is greater than $l_1$. In the end, the effect of satisfying this equation is that the two joints can be decoupled and the gravitational load can be removed from motor 2.

\subsection{Question 3}
Find $m_3$ and $l_{c3}$
\begin{flalign}
  m_3 &= m'_3 + m_B \label{eq:m3} \\
  l_{c3} &= \frac{m'_3 l'_{c3} + m_B l_B}{m'_3 + m_B} \label{eq:lc3}
\end{flalign}

\subsection{Question 4}
From (\ref{eq:cond7}), solve for $m_3$:
\begin{equation*}
  m_3 = \frac{m_4 l_{c4} - m_2 l_{c2}}{l_2}
\end{equation*}
Then substitute into (\ref{eq:cond6}) to solve for $l_{c3}$:
\begin{equation*}
  l_{c3} = \frac{m_4 l_{c4} l_1}{m_3 l_2}
\end{equation*}
Then rearrange (\ref{eq:m3}) and (\ref{eq:lc3}) to solve for $m_B$ and $l_B$:
\begin{flalign}
  m_B &= m_3 - m'_3 \\
  l_B &= \frac{l_{c3}(m'_3 + m_B) - m'_3 l'_{c3}}{m_B}
  \label{}
\end{flalign}

\subsection{Question 5}
The torsion spring introduces additional potential energy to the dynamics.
\begin{equation*}
  V (q'_1) = \frac{1}{2} k {q'_1}^2 \\
\end{equation*}
Where $q'_1 = \pi/2 - q_1$.
This potential energy ends up as an extra $\phi$ term in the dynamics equation.
\begin{equation*}
  \begin{split}
    \phi (q_1) &= \frac{\partial V}{\partial q'_1} \cdot \frac{\partial q'_1}{\partial q_1} \\
    &= k q'_1 \cdot (-1) \\
    &= -k (\frac{\pi}{2} - q_1)
  \end{split}
\end{equation*}
The new dynamics equations are:
\begin{equation}
  T_1 = ( (M)_{11} + I^1_h ) \ddot q_1 + g(m_1 l_{c1} + m_3 l_{c3} + m_4 l_1)C_{q1} - k (\frac{\pi}{2} - q_1)
\end{equation}
\begin{equation}
  T_2 = ( (M)_{22} + I^2_h ) \ddot q_2
\end{equation}

\subsection{Question 6}
Figure \ref{fig:sinq1} shows the plot of Sin(q1') vs q1' and also q1' vs q1' (45 degree reference line). The gravitional effect on motor 1 is proportional to the sine of q1'. The strength of torsional spring is linearly proportional to q1'.Therefore, a desired spring constant $k$ would create a line that can approximate the sine curve in the range between 0 to 60 degrees (0 to 1 radian). However, the figure shows that it is difficult to find a line that fits in that range. The error increases as q1' moves away from zero, and it goes up to 20\% at $q1'$=60 degrees.

\begin{figure}[htpb]
  \begin{center}
    \includegraphics[width=10cm]{sinq1}
  \end{center}
  \caption{Sin(q1') vs q1'}
  \label{fig:sinq1}
\end{figure}
